package ve.basura.entrada.util;


import org.springframework.context.ApplicationContext;
import org.springframework.context.support.ClassPathXmlApplicationContext;

import com.aseo.business.hibernate.VehiculoManager;

public class ApplicationContextUtil {

	private static ApplicationContext applicationContext = null ;
	 
	private ApplicationContextUtil(){
	}

	private synchronized static void createInstance(){
		
		if ( applicationContext==null ){
			applicationContext = new ClassPathXmlApplicationContext("ve/basura/entrada/util/applicationContext-spring.xml");
		}
	}
	
	public static ApplicationContext getAppContextInstance(){
		if(applicationContext==null) createInstance();
	
		return applicationContext;
	}
	

	/**
	 *  Wrapper para obtener un bean del contexto de spring por type
	 * 
	 * @param class1
	 * @return El bean
	 */
	public static Object getBean(Class<? extends Object > class1){
		return applicationContext.getBean(class1);
	}
	
	/**
	 * Wrapper para obtener un bean del contexto de spring por nombre
	 * 
	 * @param beanName
	 * @return El bean
	 */
	 public static Object getBean(String beanName){
		return applicationContext.getBean(beanName);
	 }


	
}
